package com.os.opencv.java.chapter5;

import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.Point;
import org.opencv.highgui.HighGui;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;

public class Rotate {

    public static void main(String[] args) {
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

        //读取图像文件并在屏幕上显示
        Mat src = Imgcodecs.imread("/Users/matt/Pictures/111.jpg");

        //读取图像并在屏幕上显示
        HighGui.imshow("src", src);
        HighGui.waitKey(0);

        //计算旋转用的仿射矩阵
        Mat dst = new Mat();
        Point center = new Point(src.width()/2.0, src.height()/2.0);
        Mat matrix = Imgproc.getRotationMatrix2D(center, 33.0, 1.0);

        //旋转图像并在屏幕上显示
        Imgproc.warpAffine(src, dst, matrix, src.size(), Imgproc.INTER_LINEAR);
        HighGui.imshow("rotated", dst);
        HighGui.waitKey(0);

        System.exit(0);


    }
}
